<?php


class Database
{
    public static $instance;

    public static $content;

    public function __construct()
    {
        $host = "165.154.134.132";
        $username = "admin";
        $password = "FCseEk2b6dBjmsLd";
        $dbname = "admin";
        // 创建连接
        $conn = new mysqli($host, $username, $password, $dbname);
        // 检查连接是否成功
        if ($conn->connect_error) {
            die("连接失败: " . $conn->connect_error);
        }
        self::$content = $conn;
    }



    public static function instance()
    {
        return self::$instance ?? new self();
    }

    public function select($sql)
    {
        $res = self::$content->query($sql);
        if ($res->num_rows > 0 ){
            return $res->fetch_assoc();
        }
        return null;
    }

    public function update($sql)
    {
        $res = self::$content->query($sql);
        return $res ? '成功' : '失败';
    }

    public function insert($sql)
    {
        $res = self::$content->query($sql);
    }
}